Documentation for Users  2.2.2
Perception Toolbox for Virtual Reality (PTVR) Manual
quit_PTVR.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 '''
3 ...\PTVR_Researchers\Python_Scripts\Demos\Interactions_events_callbacks\quit_PTVR.py
4 
5 Goal : This demo shows how the 'quit' callback allows you to instantaneously quit PTVR.exe.
6 
7 In the particular case of this script, this callback is triggered by pressing
8 the space bar (a keyboard event)
9 
10 Created on : Thu Jan 13 15:09:02 2022
11 @author: jtermozm
12 '''
13 import PTVR.SystemUtils
14 import numpy as np
15 import PTVR.Visual as visual
19 import PTVR.Data.Event as event
20 import PTVR.Data.Callback as callback
21 
22 def main():
23 
24  my_world = visual.The3DWorld ()
26 
27  my_event = event.Keyboard (valid_responses = ['space'])
28  my_callback = callback.Quit()
29 
30  my_scene.AddInteraction (events= [my_event], callbacks =[my_callback] )
31 
32  #Display Information for callback
33  my_text_press = PTVR.Stimuli.Objects.Text (text="Press space bar to Quit ",
34  position_in_current_CS = np.array([0.0,1.2,1.0]),visual_angle_of_centered_x_height_deg=1.0,
35  vertical_alignment="baseline")
36  my_scene.place (my_text_press,my_world)
37 
38  my_world.add_scene (my_scene)
39  my_world.write() # Write The3DWorld to .json file
40 
41 
42 if __name__ == "__main__":
43  main()
def LaunchThe3DWorld(jsonFileCategory="Externals")
Definition: SystemUtils.py:182
def main()
Definition: quit_PTVR.py:22